﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Business.Products;
using mozhi.smarterp.Business.Purchases.Requisition;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.Business.Controllers.Products
{
    [RemoteService]
    [Route("api/v1/products/purchase-settings")]
    public class ProductPurchaseSettingController : BusinessController
    {
        private IProductPurchaseSettingAppService _appService;

        public ProductPurchaseSettingController(IProductPurchaseSettingAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        [Route("{productId}")]
        public async Task<ProductPurchaseSettingDto> GetAsync(Guid productId)
        {
            return await _appService.GetAsync(productId);
        }

        [HttpGet]
        public async Task<PagedResultDto<ProductPurchaseSettingDto>> GetAsync(PagedAndSortedResultRequestDto filter)
        {
            return await _appService.GetListAsync(filter);
        }

        [HttpPost]
        public async Task<ProductPurchaseSettingDto> CreateAsync(ProductPurchaseSettingCreateDto input)
        {
            return await _appService.CreateAsync(input);
        }

        [HttpPut]
        public async Task<ProductPurchaseSettingDto> UpdateAsync(ProductPurchaseSettingUpdateDto input)
        {
            return await _appService.UpdateAsync(input);
        }

        [HttpDelete]
        [Route("{productId}")]
        public async Task DeleteAsync(Guid productId)
        {
            await _appService.DeleteAsync(productId);
        }
    }
}
